<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登录</title>
</head>

<body>
  <h1>登录</h1>
  <input id="username" type="text" value="" placeholder="用户名" />
  <input id="password" type="text" value="" placeholder="密码" />
  <button id="login">登录</button>
  <br />
  <br />
  <img src="http://localhost:7001/imgs/img.jpg" alt="">

  <!-- <script src="https://unpkg.com/axios/dist/axios.min.js"></script> -->
  <script src="http://localhost:7001/package/axios.min.js"></script><!-- 拦截器 -->
  <script src="http://localhost:7001/js/axios.js"></script>
  <script>
    ; (async function () {

      login.onclick = async function () {
        const res = await axios({
          method: 'post',
          url: `/api/login`,
          data: {
            username: username.value,
            password: password.value,
          }
        })


        console.log(res);

        if (res.code < 400) {
          location.href = '/'
        }


      }


    })()
  </script>
</body>

</html>